import 'dart:async';

import 'package:ride_rex/sqlite/db_interface.dart';

import '../article/comment.dart';
import '../main/discover/discover_bean.dart';
import '../main/home/landmark_bean.dart';

class DbManager {
  DbManager._init();

  static final DbManager _instance = DbManager._init();

  factory DbManager() => _instance;

  DbInterface? _dbImplements;

  ///初始化
  void init({required DbInterface dbImplements}) => _dbImplements = dbImplements;

  ///打开数据库
  static Future openDb() async => await _instance._dbImplements!.openDb();

  ///关闭数据库
  static Future closeDb() async => await _instance._dbImplements!.closeDb();

  ///存地标数据
  static Future<List<LandmarkBean>> getLandmarkData() => _instance._dbImplements!.getLandmarkData();

  ///修改地标解锁状态
  static Future updateLandmark(LandmarkBean bean) => _instance._dbImplements!.updateLandmark(bean);

  ///点赞
  static Future like({required String recordId}) => _instance._dbImplements!.like(recordId: recordId);

  ///取消点赞
  static Future cancelLike({required String recordId}) => _instance._dbImplements!.cancelLike(recordId: recordId);

  ///是否已点赞
  static Future<bool> isLike({required String recordId}) => _instance._dbImplements!.isLike(recordId: recordId);

  ///添加评论
  static Future addComment({required CommentBean bean, required String workId}) =>
      _instance._dbImplements!.addComment(bean: bean, workId: workId);

  ///获取评论列表
  static Future<List<CommentBean>> getCommentList({required String workId}) =>
      _instance._dbImplements!.getCommentList(workId: workId);

  ///获取用户列表
  static Future<List<FeedUserBean>> getLocalUserList({String? userId}) =>
      _instance._dbImplements!.getLocalUserList(userId: userId);

  ///存用户列表
  static Future saveUserList(List<FeedUserBean> userList) => _instance._dbImplements!.saveUserList(userList);

  ///关注、取消关注用户
  static Future followUser({required String userId, required String isFollow}) =>
      _instance._dbImplements!.followUser(userId: userId, isFollow: isFollow);

  ///拉黑、取消拉黑用户
  static Future blockUser({required String userId, required String isBlock}) =>
      _instance._dbImplements!.blockUser(userId: userId, isBlock: isBlock);
}
